package com.neusoft.controller;

import com.neusoft.dto.PositionConditionDto;
import com.neusoft.dto.PositionDto;
import com.neusoft.service.impl.PositionServiceImpl;
import com.neusoft.utils.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @AUTHOR 杜豪冰
 * @DATE 2025/1/8 16:36
 * @DESCRIBER
 */
@RestController
@RequestMapping("/api")
public class PositionController {
    @Autowired
    PositionServiceImpl positionService;
    @GetMapping("/positions")
    public ServerResponse getPositions(PositionConditionDto positionConditionDto){
        return positionService.getPositions(positionConditionDto);
    }

    @PostMapping("/addposition")
    public ServerResponse addPosition(@RequestBody PositionDto position) {
        return positionService.addPosition(position);
    }

    @PostMapping("/modifyposition/{no}")
    public ServerResponse modifyPosition(@RequestBody PositionDto position ,@PathVariable Integer no) {
        return positionService.modifyPosition(position,no);
    }

    @GetMapping("/position/{no}")
    public ServerResponse getPositionDetail(@PathVariable Integer no){
        return positionService.getPositionDetail(no);
    }

    @DeleteMapping("/deleteposition/{no}")
    public ServerResponse deletePosition(@PathVariable Integer no){
        return positionService.deletePositionDetail(no);
    }
}
